//
//  SMUtil.h
//  StoneMason
//
//  Created by iOS1 on 16/12/5.
//  Copyright © 2016年 iOS1. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import "AFNetWorking.h"

typedef enum {
    NetWorkFunctionPost,//default
    NetWorkFunctionGet,//
} NetWorkFunction;

@interface SMUtil : NSObject

typedef void(^sucBlock)(id data);
typedef void(^faild)(NSString *msg,int code);

/**
 *  主要网络接口请求
 *
 *  @param function   请求方式
 *  @param urlStr     请求地址
 *  @param parameters 请求参数
 *  @param success    成功block
 *  @param faild      失败block
 */
+(void)requestWithMethod:(NetWorkFunction)function with:(NSString *)urlStr parameters:(NSMutableDictionary *)parameters  success:(sucBlock)success faild:(faild)faild;

/**
 * 上传图片
 *
 * @param URLString   上传的地址
 * @param images      图片数组
 * @param parameters  参数字典
 * @param success     成功block回调
 * @param failure     失败block回调
 */
+(void)uploadImgWithUrl:(NSString *)URLString
              uploadImg:(NSArray *)images
                imgType:(NSString *)imgType
             parameters:(id)parameters
                success:(void (^)(NSURLSessionDataTask *task, id responseObject))success
                failure:(void (^)(NSURLSessionDataTask *task, NSError *error))failure;

+ (BOOL)isConnectionAvailable;

/**
 * 监听网络状态的变化
 *
 * @param networkStatus 网络状态
 */
+(void)listenNetworkStateChangeBlock:(void(^)(NSInteger status))networkStatus;

/**
 *  显示alertview
 *
 *  @param content 需要显示的字符
 */
+(void)showAlertWithStr:(NSString *)content;

@end
